import { http } from '@/utils/request'
import type { IReqAttrListParams, IReqAddEditAttr, IResAttrItem } from '@/types/attr'

/**
 * @description 获取属性列表
 * @param data
 */
export const reqAttrList = (data: IReqAttrListParams) => {
  return http<IResAttrItem[]>(
    `/admin/product/attrInfoList/${data.category1Id}/${data.category2Id}/${data.category3Id}`,
    'GET'
  )
}

/**
 * @description 新增属性或者是编辑属性
 * @param data
 */
export const reqAddEditAttr = (data: IReqAddEditAttr) => {
  return http('/admin/product/saveAttrInfo', 'POST', data)
}

/**
 * @description 删除属性
 * @param id
 */
export const reqDelAttr = (id: number) => {
  return http(`/admin/product/deleteAttr/${id}`, 'DELETE')
}
